<%--
  Created by IntelliJ IDEA.
  User: 29276
  Date: 2021/8/22
  Time: 17:35
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    //http://localhost:8080/01_sxtoa_war_exploded/
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
    <base href="<%=basePath%>"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>无标题文档</title>
    <link href="css/style.css" rel="stylesheet" type="text/css" />
    <link href="css/select.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript" src="js/jquery.js"></script>

    <script type="text/javascript" src="js/jquery.idTabs.min.js"></script>
    <script type="text/javascript" src="js/select-ui.min.js"></script>
    <script type="text/javascript" src="editor/kindeditor.js"></script>
    <script type="text/javascript">
        $(document).ready(function(e) {
            $(".select1").uedSelect({
                width : 200
            });

        });
    </script>
    <script type="text/javascript">
        $(document).ready(function(){
            $(".click").click(function(){
                $(".tip").fadeIn(200);
            });

            $(".tiptop a").click(function(){
                $(".tip").fadeOut(200);
            });

            $(".sure").click(function(){
                $(".tip").fadeOut(100);
            });

            $(".cancel").click(function(){
                $(".tip").fadeOut(100);
            });

        });
    </script>

    <script type="text/javascript">
        $(function () {
            var pNum = 1;
            var pSize = 2;
            var pages;

            $("#pageUp").click(function () {
                console.log("上一页");
                console.log(pNum);
                if (pNum !== 1) {
                    ajaxPage(--pNum, pSize);
                } else {
                    alert("当前是第一页");
                }
                console.log("返回值：" + pNum);
            })

            $("#pageDown").click(function () {
                console.log("下一页");
                console.log(pNum);
                if (pNum !== pages) {
                    ajaxPage(++pNum, pSize);
                } else {
                    alert("当前是最后一页");
                }
                console.log("返回值：" + pNum);
            })

            ajaxPage(1, pSize);

            function ajaxPage(pNum, pSize) {


                const reqData = {
                    methodName: "myDutyList",
                    pageNum: pNum,
                    pageSize: pSize
                };
                $.post("dutyServlet", reqData, function (data) {
                    if (data === "sessionTimeOut") {
                        window.location.href = "login.jsp";
                        return;
                    }
                    eval("var result=" + data);
                    var ds = result.list;
                    pages = result.pages;
                    var totle = result.size;

                    $("#total").html(totle);
                    $("#pageNum").html(pNum);

                    $("#pageUl>li:not(#pageUp,#pageDown)").remove();
                    for (var i = 1; i <= pages; i++) {
                        $("#pageDown").before("<li class=\"paginItem\"><a class='page' id='" + i + "' href=\"javascript:;\">" + i + "</a></li>");
                    }
                    $(".page").click(function () {
                        console.log("点击数字：" + this.id);
                        console.log(this.id);
                        pNum = this.id;
                        console.log(pNum);
                        ajaxPage(pNum, pSize);
                        console.log("返回值：" + pNum);
                    })
                    const tb = $("#tb");
                    tb.empty();
                    for (i = 0; i < ds.length; i++) {
                        tb.append("<tr>\n" +
                            "            <td>\n" +
                            "                <input name=\"\" type=\"checkbox\" value=\"\" />\n" +
                            "            </td>\n" +
                            "            <td>"+ds[i].dutyDate+"</td>\n" +
                            "            <td>"+ds[i].signInTime+"</td>\n" +
                            "            <td>"+ds[i].signOutTime+"</td>\n" +
                            "        </tr>");

                    }
                })
            }
        })
    </script>

</head>

<body>

<div class="place">
    <span>位置：</span>
    <ul class="placeul">
        <li><a href="#">考勤管理</a></li>
        <li><a href="#">我的考勤</a></li>
    </ul>
</div>

<div class="rightinfo">


    <div class="formtitle1"><span>我的考勤</span></div>

    <table class="tablelist">
        <thead>
        <tr>
            <th>
                <input name="" type="checkbox" value="" checked="checked" />
            </th>
            <th>出勤日期</th>
            <th>签到时间</th>
            <th>签退时间</th>
        </tr>
        </thead>
        <tbody id="tb">
        </tbody>
    </table>

    <div class="pagin">
        <div class="message">共<i id="total" class="blue"></i>条记录，当前显示第&nbsp;<i id="pageNum" class="blue">&nbsp;</i>页
        <ul id="pageUl" class="paginList">
            <li class="paginItem" id="pageUp"><a href="javascript:;"><span class="pagepre"></span></a></li>
            <li class="paginItem" id="pageDown"><a href="javascript:;"><span class="pagenxt"></span></a></li>
        </ul>
    </div>

    <div class="tip">
        <div class="tiptop"><span>提示信息</span>
            <a></a>
        </div>

        <div class="tipinfo">
            <span><img src="images/ticon.png" /></span>
            <div class="tipright">
                <p>是否确认对信息的修改 ？</p>
                <cite>如果是请点击确定按钮 ，否则请点取消。</cite>
            </div>
        </div>

        <div class="tipbtn">
            <input name="" type="button" class="sure" value="确定" />&nbsp;
            <input name="" type="button" class="cancel" value="取消" />
        </div>

    </div>

</div>

<script type="text/javascript">
    $('.tablelist tbody tr:odd').addClass('odd');
</script>

</body>

</html>
